package com.wanxi.exception;

import java.util.Scanner;

public class PrintStudent {
    public static void main(String[] args) {

        while (true) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入年龄");
            int age = 0;
            try {
                age = scanner.nextInt();
            } catch (Exception e) {
                e.printStackTrace();
                age=1;
            }

            if (age >= 18 && age <= 25) {
                Student student = new Student("", age);
                System.out.println(student);
                break;
            } else {
                System.out.println("你输入的年龄有误");
            }
        }


    }
}
